%option noyywrap nodefault yylineno

%{

%}

EXP ([Ee][-+]?[0-9]+)

%%

"+" |
"-" |
"*" |
"/" |
"%" |
"=" |
"|" |
"," |
";" |
"(" |
")" |
"{" |
"}" |
"[" |
"]"   { return yytext[0]; } /* normal opertator */

">" {yylval.fn = 1; return CMP; }
"<" {yylval.fn = 2; return CMP; }
"<>" {yylval.fn = 3; return CMP; }
"==" {yylval.fn = 4; return CMP; }
">=" {yylval.fn = 5; return CMP; }
"<=" {yylval.fn = 6; return CMP; }

"&" { yylval.fn = 7; return GETADR; }
"&&" { yylval.fn = 8; return LOGIC; }
"||" { yylval.fn = 9; return LOGIC; }

"if" { return IF; }
"else" { return ELSE; }
"for" { return FOR; }
"while" { return WHILE; }

"void" { return VOID; }
"int" { return INT; }
"double" { return DOUBLE; }
"char" { return CHAR; }

"return" { return RETURN; }
"continue" { return CONTINUE; }
"break" { return BREAK; }

"sqrt" { yylval.fn = B_sqrt; return FUNC; }
"exp" { yylval.fn = B_exp; return FUNC; }
"log" { yylval.fn = B_log; return FUNC; }
"print" { yylval.fn = B_print; return FUNC; }

[a-zA-Z][a-zA-Z0-9]* { yylval.s = lookup(yytext); return IDENTIFIER; }
[0-9]+ { yylval.i = atoi(yytext); return INTEGER; }
[0-9]+"."[0-9]*{EXP}? { yylval.d = atof(yytext); return FLOAT; }

"//".*
[ \t]

\\\n  { printf("...>"); }
\n { return EOL;}
. { yyerror("unknown character %c\n", *yytext); }
%%
